package org.selenium.in;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
		
public class AddToCart {
	private static final String URL = "http://www.flipkart.com";
	WebDriver driver;
	HomePage homePage;
	SearchPage searchPage;

	@Before
	public void launchApp() {
		if(driver == null){ 
		driver = new FirefoxDriver();	
		driver.navigate().to(URL);
		homePage = new HomePage(driver);
		searchPage= new SearchPage(driver);
	}		
	}
	
	@Test
	public void addtToCart()throws Exception
	{
		String searchString="Casino royale";
		homePage.searchString(searchString);
		searchPage.clickOnSearchResults("Books");
		searchPage.clickOnSearchResults("James Bond: Casino Royale");
		searchPage.clickOnAddToCart();
				
	}
	
	@After
	public void tearDown(){
		driver.close();
	}

}
